package com.qms.repast.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.qms.repast.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author 泅渡者
 * @date 2018/8/9 0009
 * @describe: 订单确认适配器
 */
public class OrderConfirmAdapter extends RecyclerView.Adapter<OrderConfirmAdapter.Viewholder> {


	private Context context;
	private List<String> data;
	private String userId;
	private String shopId;

	public OrderConfirmAdapter (Context context) {
		this.context = context;
		data = new ArrayList<>();
	}

	public void setList (List<String> list, String userId, String shopId) {
		this.shopId = shopId;
		this.userId = userId;
		data.clear();
		data.addAll(list);
		notifyDataSetChanged();
	}

	@Override
	public Viewholder onCreateViewHolder (ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(context).inflate(R.layout.layout_order_confirm_item, parent, false);
		return new Viewholder(view);
	}

	@Override
	public void onBindViewHolder (final Viewholder holder, final int position) {

	}

	@Override
	public int getItemCount () {
		return data.size();
	}


	/**
	 * view.getWidth()获取的是屏幕中可以看到的大小.
	 */
	public class Viewholder extends RecyclerView.ViewHolder {

		@BindView(R.id.iv_image)
		public ImageView ivImage;
		@BindView(R.id.tv_name)
		public TextView tvName;
		@BindView(R.id.tv_oldPriceAll)
		public TextView tvOldPriceAll;
		@BindView(R.id.tv_newPriceAll)
		public TextView tvNewPriceAll;
		@BindView(R.id.tv_sum)
		public TextView tvSum;

		public Viewholder (View itemView) {
			super(itemView);
			ButterKnife.bind(this, itemView);
		}

	}
}
